m_HDUnitCommands = m_HDUnitCommands or {};
m_HDUnitCommands.KURUMI_ALEPH = {
	EventName = 'HD_Kurumi_Aleph',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNITCOMMAND_KURUMI_ALEPH',
	ToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_ALEPH_NAME') .. '[NEWLINE][NEWLINE]' .. Locale.Lookup('LOC_UNITCOMMAND_KURUMI_ALEPH_DESCRIPTION'),
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.KURUMI_ALEPH.CanUse(unit)
	if unit == nil then
		return false;
	end
	return GameInfo.Units[unit:GetType()].BaseMoves > 0;
end
function m_HDUnitCommands.KURUMI_ALEPH.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local playerConfig = PlayerConfigurations[playerId];
	local leader = playerConfig:GetLeaderTypeName();
	return ExposedMembers.DLHD.Utils.LeaderHasTrait(leader, 'TRAIT_LEADER_TOKISAKI_KURUMI');
end
function m_HDUnitCommands.KURUMI_ALEPH.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local resourceInfo = GameInfo.Resources['RESOURCE_KURUMI_TIME'];
	if resourceInfo == nil then
		return true;
	end
	return player:GetResources():GetResourceAmount(resourceInfo.Index) < 3;
end

m_HDUnitCommands.KURUMI_BET = {
	EventName = 'HD_Kurumi_Bet',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNITCOMMAND_KURUMI_BET',
	ToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_BET_NAME') .. '[NEWLINE][NEWLINE]' .. Locale.Lookup('LOC_UNITCOMMAND_KURUMI_BET_DESCRIPTION'),
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.KURUMI_BET.CanUse(unit)
	if unit == nil then
		return false;
	end
	return true;
end
function m_HDUnitCommands.KURUMI_BET.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local playerConfig = PlayerConfigurations[playerId];
	local leader = playerConfig:GetLeaderTypeName();
	return ExposedMembers.DLHD.Utils.LeaderHasTrait(leader, 'TRAIT_LEADER_TOKISAKI_KURUMI');
end
function m_HDUnitCommands.KURUMI_BET.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local resourceInfo = GameInfo.Resources['RESOURCE_KURUMI_TIME'];
	if resourceInfo == nil then
		return true;
	end
	return player:GetResources():GetResourceAmount(resourceInfo.Index) < 2;
end

m_HDUnitCommands.KURUMI_GIMEL = {
	EventName = 'HD_Kurumi_Gimel',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNITCOMMAND_KURUMI_GIMEL',
	ToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_GIMEL_NAME') .. '[NEWLINE][NEWLINE]' .. Locale.Lookup('LOC_UNITCOMMAND_KURUMI_GIMEL_DESCRIPTION'),
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.KURUMI_GIMEL.CanUse(unit)
	if unit == nil then
		return false;
	end
	local unitInfo = GameInfo.Units[unit:GetType()];
	if unitInfo == nil then
		return false;
	end
	return unitInfo.PromotionClass ~= nil;
end
function m_HDUnitCommands.KURUMI_GIMEL.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local playerConfig = PlayerConfigurations[playerId];
	local leader = playerConfig:GetLeaderTypeName();
	return ExposedMembers.DLHD.Utils.LeaderHasTrait(leader, 'TRAIT_LEADER_TOKISAKI_KURUMI');
end
function m_HDUnitCommands.KURUMI_GIMEL.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local resourceInfo = GameInfo.Resources['RESOURCE_KURUMI_TIME'];
	if resourceInfo == nil then
		return true;
	end
	return player:GetResources():GetResourceAmount(resourceInfo.Index) < 4;
end

m_HDUnitCommands.KURUMI_DALET = {
	EventName = 'HD_Kurumi_Dalet',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNITCOMMAND_KURUMI_DALET',
	ToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DALET_NAME') .. '[NEWLINE][NEWLINE]' .. Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DALET_DESCRIPTION'),
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.KURUMI_DALET.CanUse(unit)
	if unit == nil then
		return false;
	end
	local unitInfo = GameInfo.Units[unit:GetType()];
	if unitInfo == nil then
		return false;
	end
	return (unitInfo.FormationClass == 'FORMATION_CLASS_LAND_COMBAT') or (unitInfo.FormationClass == 'FORMATION_CLASS_NAVAL') or (unitInfo.FormationClass == 'FORMATION_CLASS_AIR');
end
function m_HDUnitCommands.KURUMI_DALET.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local playerConfig = PlayerConfigurations[playerId];
	local leader = playerConfig:GetLeaderTypeName();
	return (unit:GetDamage()) > 0 and ExposedMembers.DLHD.Utils.LeaderHasTrait(leader, 'TRAIT_LEADER_TOKISAKI_KURUMI');
end
function m_HDUnitCommands.KURUMI_DALET.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local resourceInfo = GameInfo.Resources['RESOURCE_KURUMI_TIME'];
	if resourceInfo == nil then
		return true;
	end
	return player:GetResources():GetResourceAmount(resourceInfo.Index) < 4;
end

m_HDUnitCommands.KURUMI_ZAYIN = {
	EventName = 'HD_Kurumi_Zayin',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNITCOMMAND_KURUMI_ZAYIN',
	ToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_ZAYIN_NAME') .. '[NEWLINE][NEWLINE]' .. Locale.Lookup('LOC_UNITCOMMAND_KURUMI_ZAYIN_DESCRIPTION'),
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_KURUMI_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.KURUMI_ZAYIN.CanUse(unit)
	if unit == nil then
		return false;
	end
	local unitInfo = GameInfo.Units[unit:GetType()];
	if unitInfo == nil then
		return false;
	end
	return (unitInfo.FormationClass == 'FORMATION_CLASS_LAND_COMBAT') or (unitInfo.FormationClass == 'FORMATION_CLASS_NAVAL') or (unitInfo.FormationClass == 'FORMATION_CLASS_AIR');
end
function m_HDUnitCommands.KURUMI_ZAYIN.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local playerConfig = PlayerConfigurations[playerId];
	local leader = playerConfig:GetLeaderTypeName();
	return ExposedMembers.DLHD.Utils.LeaderHasTrait(leader, 'TRAIT_LEADER_TOKISAKI_KURUMI');
end
function m_HDUnitCommands.KURUMI_ZAYIN.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local resourceInfo = GameInfo.Resources['RESOURCE_KURUMI_TIME'];
	if resourceInfo == nil then
		return true;
	end
	return player:GetResources():GetResourceAmount(resourceInfo.Index) < 9;
end

local WITCH_TIME_KEY = 'WITCH_TIME';
m_HDUnitCommands.NATSUMI_WITCH_IMPROVE = {
	EventName = 'HD_Natsumi_WitchImprove',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNIT_NATSUMI_WITCH',
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_NATSUMI_WITCH_IMPROVE_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.NATSUMI_WITCH_IMPROVE.GetToolTipString (unit)
	-- basic
	local s = Locale.Lookup('LOC_UNITCOMMAND_NATSUMI_WITCH_IMPROVE_DESCRIPTION');
	if unit == nil then
		return s;
	end
	-- remaining times
	local times = (GlobalParameters.WITCH_ACTIVATION_CHARGE or 0) - (unit:GetProperty(WITCH_TIME_KEY) or 0);
	s = s .. "[NEWLINE]" .. Locale.Lookup("LOC_UNITCOMMAND_NATSUMI_WITCH_IMPROVE_CHARGES", times);
	return s;
end
function m_HDUnitCommands.NATSUMI_WITCH_IMPROVE.CanUse(unit)
	if unit == nil then
		return false;
	end
	local unitInfo = GameInfo.Units[unit:GetType()];
	if unitInfo == nil then
		return false;
	end
	return unitInfo.UnitType == 'UNIT_NATSUMI_WITCH';
end
function m_HDUnitCommands.NATSUMI_WITCH_IMPROVE.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local times = unit:GetProperty(WITCH_TIME_KEY) or 0;
	return times < (GlobalParameters.WITCH_ACTIVATION_CHARGE or 0);
end
function m_HDUnitCommands.NATSUMI_WITCH_IMPROVE.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	local location = unit:GetLocation();
	local city = CityManager.GetCityAt(location.x, location.y);
	if city == nil then
		return true;
	end
	return city:GetOwner() ~= unit:GetOwner();
end

m_HDUnitCommands.NATSUMI_WITCH_COPY = {
	EventName = 'HD_Natsumi_WitchCopy',
	CategoryInUI = 'SPECIFIC',
	Icon = 'ICON_UNIT_NATSUMI_WITCH',
	ToolTipString = Locale.Lookup('LOC_UNITCOMMAND_NATSUMI_WITCH_COPY_DESCRIPTION'),
	DisabledToolTipString = Locale.Lookup('LOC_UNITCOMMAND_NATSUMI_WITCH_COPY_DISABLED_TT'),
	VisibleInUI = true,
	DoNotDelete = true
};
function m_HDUnitCommands.NATSUMI_WITCH_COPY.CanUse(unit)
	if unit == nil then
		return false;
	end
	local unitInfo = GameInfo.Units[unit:GetType()];
	if unitInfo == nil then
		return false;
	end
	return unitInfo.UnitType == 'UNIT_NATSUMI_WITCH';
end
function m_HDUnitCommands.NATSUMI_WITCH_COPY.IsVisible(unit)
	if unit == nil then
		return false;
	end
	local playerId = unit:GetOwner();
	local player = Players[playerId];
	local playerConfig = PlayerConfigurations[playerId];
	local leader = playerConfig:GetLeaderTypeName();
	return ExposedMembers.DLHD.Utils.LeaderHasTrait(leader, 'TRAIT_LEADER_KYONO_NATSUMI');
	
end
function m_HDUnitCommands.NATSUMI_WITCH_COPY.IsDisabled(unit)
	if unit == nil then
		return false;
	end
	return false;
end
